package com.extrace.server.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;

@Entity
@Data
@Table(name="transpackage")
public class Transpackage {
    @Id
    private String id;

    private String eid; // 对应的快件的 id 这里面子考虑了一个快件一个包裹
    private Integer creater;
    @Column(name = "create_time")
    @TableField(value = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp createTime;
    private Integer packer; // 打包人的 Id
    @Column(name = "pack_time")
    @TableField(value = "pack_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp packTime;
    private Integer unpacker; // 拆包人的 id
    @Column(name = "unpack_time")
    @TableField(value = "unpack_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp unpackTime;
    private Integer status; // 包裹状态
    private Integer transporter; // 运输人的 id
    @Column(name = "start_node")
    @TableField(value = "start_node")
    private String startNode; // 出发地的 id
    @Transient
    @TableField(exist = false)
    private String startNodeName; // 出发地
    @Column(name = "start_time")
    @TableField(value = "start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp startTime;

    @Column(name = "end_node")
    @TableField(value = "end_node")
    private String endNode; // 目的地的 id
    @Transient
    @TableField(exist = false)
    private String endNodeName; // 目的地
    private Integer ender; // 接收包裹的人的 id
    @Column(name = "end_time")
    @TableField(value = "end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp endTime;


    @Override
    public String toString() {
        return "Transpackage{" +
                "id='" + id + '\'' +
                ", creater=" + creater +
                ", createTime=" + createTime +
                ", packer=" + packer +
                ", packTime=" + packTime +
                ", unpacker=" + unpacker +
                ", unpackTime=" + unpackTime +
                ", status=" + status +
                ", transporter=" + transporter +
                ", startNode='" + startNode + '\'' +
                ", startNodeName='" + startNodeName + '\'' +
                ", startTime=" + startTime +
                ", endNode='" + endNode + '\'' +
                ", endNodeName='" + endNodeName + '\'' +
                ", ender=" + ender +
                ", endTime=" + endTime +
                '}';
    }

    public static final class STATUS{
        public static final int STATUS_CREATED = 0;  // 包裹已创建
        public static final int STATUS_PACKED = 1;  // 包裹已打包
        public static final int STATUS_TRANSPORTING = 2;  // 包裹运输中
        public static final int STATUS_ARRIVED = 3;  // 包裹已到达
        public static final int STATUS_UNPACKED = 4;  // 包裹已拆包
    }
}
